package com.gitee.swsk33.dborder.api;

import com.gitee.swsk33.dbentity.dataobject.Order;
import com.gitee.swsk33.dbentity.model.Result;
import com.gitee.swsk33.dborder.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/order")
public class OrderAPI {

	@Autowired
	private OrderService orderService;

	@PostMapping("/add")
	public Result<Void> add(@RequestBody Order order) {
		return orderService.add(order);
	}

	@DeleteMapping("/delete/{id}")
	public Result<Void> delete(@PathVariable int id) {
		return orderService.delete(id);
	}

	@GetMapping("/get/{id}")
	public Result<Order> getById(@PathVariable int id) {
		return orderService.getById(id);
	}

	@PostMapping("/get-batch")
	public Result<List<Order>> getByBatchId(@RequestBody List<Integer> ids) {
		return orderService.getByBatchId(ids);
	}

}